import request from "@/utils/request";
import type {
  SpuArguments,
  SpuPage,
  spuBaseAttrList,
  addSpuType,
  spuImageList,
  spuSaleAttrList,
  spuType,
} from "./type/spuType";
const enum Api {
  getSPUAttrList = "/admin/product",
  getSpuBaseAttr = "/admin/product/baseSaleAttrList",
  addSpuBaseAttr = "/admin/product/saveSpuInfo",
  getSpuImageList = "/admin/product/spuImageList",
  getSpuSaleAttrList = "/admin/product/spuSaleAttrList",
  updateSkuInfo = "/admin/product/updateSkuInfo",
}
// 获取spu属性列表
export const SPUAttrListApi = ({ page, limit, category3Id }: SpuArguments) => {
  return request.get<any, SpuPage>(Api.getSPUAttrList + `/${page}/${limit}`, {
    params: { category3Id },
  });
};
// 获取添加属性中的下拉框基本销售属性
export const SpuBaseAttrApi = () => {
  return request.get<any, spuBaseAttrList>(Api.getSpuBaseAttr);
};
// 添加spu属性
export const addSpuBaseAttrApi = (data: addSpuType) => {
  return request.post<any, null>(Api.addSpuBaseAttr, data);
};
// 获取图片数据
export const getSpuImageListApi = (spuId: number) => {
  return request.get<any, spuImageList>(Api.getSpuImageList + `/${spuId}`);
};
// 获取销售属性数据
export const getSpuSaleAttrListApi = (spuId: number) => {
  return request.get<any, spuSaleAttrList>(
    Api.getSpuSaleAttrList + `/${spuId}`
  );
};
// 修改spu
export const updateSkuInfoApi = (data: addSpuType) => {
  return request.post<any, null>(Api.updateSkuInfo, data);
};
